package cn.seczone.iast.agent;

import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.AdviceAdapter;

/**
 * @author XieShaoping
 */
public class MyAdapter extends AdviceAdapter {

    public static final String CLASS_PATH = InjectMethod.class.getName().replace(".", "/");

    public MyAdapter(MethodVisitor mv, int access, String name, String desc) {
        super(Opcodes.ASM9, mv, access, name, desc);
    }

    @Override
    protected void onMethodEnter() {
        Label label0 = new Label();
        mv.visitLabel(label0);
        mv.visitMethodInsn(INVOKESTATIC, "cn/seczone/iast/engine/globalstorage/config/PortalConfig", "getCommonConfig", "()Lcn/seczone/iast/engine/globalstorage/config/bean/CommonConfig;", false);
        mv.visitMethodInsn(INVOKEVIRTUAL, "cn/seczone/iast/engine/globalstorage/config/bean/CommonConfig", "isApm", "()Z", false);
        Label label1 = new Label();
        mv.visitJumpInsn(IFNE, label1);
        Label label2 = new Label();
        mv.visitLabel(label2);
        mv.visitInsn(RETURN);
        mv.visitLabel(label1);
        mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
    }

}